package com.itheima.controller;

import com.itheima.dimain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author cxl
 * @date 2020-02-13 21:51
 */
@ControllerAdvice
@RequestMapping("/user")
@ResponseBody
public class UserController {
    @Autowired
    private UserService userService;
@RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.finAll();
    }
    @RequestMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }
    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user){
    userService.updateUser(user);
    }
    @RequestMapping("/deleteUser")
    public void deleteUser(Integer id){
    userService.deleteUser(id);
    }
    @RequestMapping("/addUser")
    public void addUser(@RequestBody User user){
        userService.addUser(user);
    }
}
